home *** CD-ROM | disk | FTP | other *** search
/ Language/OS - Multiplatform Resource Library / LANGUAGE OS.iso / cocktail / rpp.lha / rpp / m2c / Scanner.c < prev    next >
C/C++ Source or Header  |  1992-08-18  |  33KB  |  1,483 lines

  1. #include "SYSTEM_.h"
  2.  
  3. #ifndef DEFINITION_Checks
  4. #include "Checks.h"
  5. #endif
  6.  
  7. #ifndef DEFINITION_System
  8. #include "System.h"
  9. #endif
  10.  
  11. #ifndef DEFINITION_Positions
  12. #include "Positions.h"
  13. #endif
  14.  
  15. #ifndef DEFINITION_IO
  16. #include "IO.h"
  17. #endif
  18.  
  19. #ifndef DEFINITION_Memory
  20. #include "Memory.h"
  21. #endif
  22.  
  23. #ifndef DEFINITION_Strings
  24. #include "Strings.h"
  25. #endif
  26.  
  27. #ifndef DEFINITION_Source
  28. #include "Source.h"
  29. #endif
  30.  
  31. #ifndef DEFINITION_System
  32. #include "System.h"
  33. #endif
  34.  
  35. #ifndef DEFINITION_Strings
  36. #include "Strings.h"
  37. #endif
  38.  
  39. #ifndef DEFINITION_StringMem
  40. #include "StringMem.h"
  41. #endif
  42.  
  43. #ifndef DEFINITION_Idents
  44. #include "Idents.h"
  45. #endif
  46.  
  47. #ifndef DEFINITION_IO
  48. #include "IO.h"
  49. #endif
  50.  
  51. #ifndef DEFINITION_Scanner
  52. #include "Scanner.h"
  53. #endif
  54.  
  55. struct Scanner_2 Scanner_InfoFileName;
  56. CARDINAL Scanner_TokenLength;
  57. Scanner_tScanAttribute Scanner_Attribute;
  58. struct Scanner_3 Scanner_ScanTabName;
  59. PROC Scanner_Exit;
  60.  
  61. static CHAR MissingInfo [] = "rpp: cannot access file <Scanner>.rpp";
  62. static CARDINAL Level;
  63. static Strings_tString StartString;
  64. static Strings_tString TheWord;
  65. static BOOLEAN IsCollecting;
  66. static BOOLEAN BothFlag;
  67. static BOOLEAN Returning;
  68. static Strings_tString InsText;
  69. static IO_tFile InfoFile;
  70. static Idents_tIdent LastIdent;
  71. static struct S_2 {
  72.     SHORTCARD A[1023 + 1];
  73. } TokenCode;
  74. static struct S_3 {
  75.     StringMem_tStringRef A[1023 + 1];
  76. } TokenSelector;
  77. static Strings_tString Not1, Not2, Not3;
  78. static Strings_tString Any1, Any2, Any3;
  79. static struct S_4 {
  80.     CHAR A[127 + 1];
  81. } Argument;
  82. static SHORTCARD i;
  83. #define Modula    0
  84. #define C    1
  85. static unsigned char Language;
  86. static void Skip ARGS(());
  87. static void DoText ARGS(());
  88. static void DoIdent ARGS(());
  89. static void CopyText ARGS(());
  90. static void GenPosition ARGS(());
  91. static void GenScanAttr ARGS(());
  92. static void GenErrorAttr ARGS(());
  93. static void ReadIdents ARGS(());
  94. struct S_15 {
  95.     CHAR A[255 + 1];
  96. };
  97. static void InsertRules ARGS(());
  98. struct S_16 {
  99.     CHAR A[255 + 1];
  100. };
  101. static void WriteIdent ARGS((Strings_tString *TheWord));
  102. struct S_17 {
  103.     CHAR A[255 + 1];
  104. };
  105. #define yyDNoState    0
  106. #define yyFileStackSize    16
  107. #define yyTokenLngMax    256
  108. #define yyChBufferSize    2048
  109. #define yyFirstCh    '\0'
  110. #define yyLastCh    ((CHAR)'\177')
  111. #define yyEolCh    '\n'
  112. #define yyEobCh    ((CHAR)'\177')
  113. #define yyDStateCount    154
  114. #define yyTableSize    1254
  115. #define yyEobState    132
  116. #define yyDefaultState    133
  117. #define STD    1
  118. #define Return    3
  119. #define Start    5
  120. #define Action    7
  121. #define Rules    9
  122. #define Set    11
  123. typedef SHORTCARD yyTableElmt;
  124. typedef yyTableElmt yyStateRange;
  125. typedef yyTableElmt yyTableRange;
  126. typedef struct S_1 {
  127.     yyStateRange Check, Next;
  128. } yyCombType;
  129. typedef yyCombType *yyCombTypePtr;
  130. typedef SHORTCARD yyStStackRange;
  131. typedef SHORTCARD yyChBufferRange;
  132. typedef struct S_5 {
  133.     CHAR A[yyTokenLngMax + yyChBufferSize + 3 + 1];
  134. } *yyChBufferType;
  135. typedef CHAR yyChRange;
  136. static struct S_6 {
  137.     LONGCARD A[yyDStateCount + 1];
  138. } yyBasePtr;
  139. static struct S_7 {
  140.     yyStateRange A[yyDStateCount + 1];
  141. } yyDefault;
  142. static struct S_8 {
  143.     yyCombType A[yyTableSize + 1];
  144. } yyComb;
  145. static struct S_9 {
  146.     yyStateRange A[yyDStateCount + 1];
  147. } yyEobTrans;
  148. static struct S_10 {
  149.     CHAR A[yyLastCh + 1];
  150. } yyToLower, yyToUpper;
  151. static struct S_11 {
  152.     yyStateRange A[yyTokenLngMax + 1];
  153. } yyStateStack;
  154. static yyStateRange yyStartState;
  155. static yyStateRange yyPreviousStart;
  156. static CHAR yyCh;
  157. static System_tFile yySourceFile;
  158. static yyChBufferType yyChBufferPtr;
  159. static yyChBufferRange yyChBufferIndex;
  160. static SHORTINT yyBytesRead;
  161. static BOOLEAN yyEof;
  162. static CARDINAL yyLineCount;
  163. static yyChBufferRange yyLineStart;
  164. static SHORTCARD yyFileStackPtr;
  165. static struct S_12 {
  166.     struct S_13 {
  167.         System_tFile SourceFile;
  168.         yyChBufferType ChBufferPtr;
  169.         yyChBufferRange ChBufferIndex;
  170.         SHORTINT BytesRead;
  171.         BOOLEAN Eof;
  172.         CARDINAL LineCount;
  173.         yyChBufferRange LineStart;
  174.     } A[yyFileStackSize - 1 + 1];
  175. } yyFileStack;
  176. static void yyInitialize ARGS(());
  177. static void yyStart ARGS((yyStateRange State));
  178. static void yyPrevious ARGS(());
  179. static void yyEcho ARGS(());
  180. static void yyLess ARGS((CARDINAL n));
  181. static void yyTab ARGS(());
  182. static void yyTab1 ARGS((CARDINAL a));
  183. static void yyTab2 ARGS((CARDINAL a, CARDINAL b));
  184. static void yyEol ARGS((CARDINAL Column));
  185. static void output ARGS((CHAR c));
  186. static void unput ARGS((CHAR c));
  187. static CHAR input ARGS(());
  188. static void yyGetTables ARGS(());
  189. struct S_18 {
  190.     yyTableRange A[yyDStateCount + 1];
  191. };
  192. static CARDINAL yyGetTable ARGS((System_tFile TableFile, ADDRESS Address));
  193. static void yyErrorMessage ARGS((SHORTCARD ErrorCode));
  194. static void yyExit ARGS(());
  195.  
  196.  
  197. static void Skip
  198. # ifdef __STDC__
  199. ()
  200. # else
  201. ()
  202. # endif
  203. {
  204.   do {
  205.     Strings_ReadL(InfoFile, &TheWord);
  206.   } while (!(Strings_Length(&TheWord) == 2 && Strings_Char(&TheWord, 1) == '%' && Strings_Char(&TheWord, 2) == '%'));
  207. }
  208.  
  209. static void DoText
  210. # ifdef __STDC__
  211. ()
  212. # else
  213. ()
  214. # endif
  215. {
  216.   if (!IsCollecting) {
  217.     yyEcho();
  218.   } else if (Level > 0) {
  219.     Scanner_GetWord(&TheWord);
  220.     Strings_Concatenate(&InsText, &TheWord);
  221.   }
  222. }
  223.  
  224. static void DoIdent
  225. # ifdef __STDC__
  226. ()
  227. # else
  228. ()
  229. # endif
  230. {
  231.   Idents_tIdent i;
  232.  
  233.   Scanner_GetWord(&TheWord);
  234.   i = Idents_MakeIdent(&TheWord);
  235.   if (i <= LastIdent) {
  236.     if (Returning) {
  237.       Strings_IntToString((LONGINT)TokenCode.A[i], &TheWord);
  238.     } else {
  239.       StringMem_GetString(TokenSelector.A[i], &TheWord);
  240.     }
  241.     if (IsCollecting) {
  242.       Strings_Concatenate(&InsText, &TheWord);
  243.     } else {
  244.       Strings_WriteS((System_tFile)IO_StdOutput, &TheWord);
  245.     }
  246.   } else {
  247.     if (IsCollecting) {
  248.       Strings_Concatenate(&InsText, &TheWord);
  249.     } else {
  250.       yyEcho();
  251.     }
  252.   }
  253. }
  254.  
  255. static void CopyText
  256. # ifdef __STDC__
  257. ()
  258. # else
  259. ()
  260. # endif
  261. {
  262.   for (;;) {
  263.     Strings_ReadL(InfoFile, &TheWord);
  264.     if (Strings_Length(&TheWord) == 2 && Strings_Char(&TheWord, 1) == '%' && Strings_Char(&TheWord, 2) == '%') {
  265.       goto EXIT_1;
  266.     }
  267.     Strings_WriteL((System_tFile)IO_StdOutput, &TheWord);
  268.   } EXIT_1:;
  269. }
  270.  
  271. static void GenPosition
  272. # ifdef __STDC__
  273. ()
  274. # else
  275. ()
  276. # endif
  277. {
  278.   switch (Language) {
  279.   case Modula:;
  280.     IO_WriteS((System_tFile)IO_StdOutput, (STRING)"FROM Positions IMPORT tPosition;", 32L);
  281.     break;
  282.   case C:;
  283.     IO_WriteS((System_tFile)IO_StdOutput, (STRING)"# include \"Positions.h\"", 23L);
  284.     break;
  285.   default :
  286.     break;
  287.   }
  288.   IO_WriteNl((System_tFile)IO_StdOutput);
  289. }
  290.  
  291. static void GenScanAttr
  292. # ifdef __STDC__
  293. ()
  294. # else
  295. ()
  296. # endif
  297. {
  298.   InfoFile = IO_ReadOpen(Scanner_InfoFileName.A, 256L);
  299.   Strings_ReadL(InfoFile, &TheWord);
  300.   CopyText();
  301.   IO_ReadClose(InfoFile);
  302. }
  303.  
  304. static void GenErrorAttr
  305. # ifdef __STDC__
  306. ()
  307. # else
  308. ()
  309. # endif
  310. {
  311.   InfoFile = IO_ReadOpen(Scanner_InfoFileName.A, 256L);
  312.   Skip();
  313.   CopyText();
  314.   IO_ReadClose(InfoFile);
  315. }
  316.  
  317. static void ReadIdents
  318. # ifdef __STDC__
  319. ()
  320. # else
  321. ()
  322. # endif
  323. {
  324.   INTEGER t, i;
  325.   CHAR c;
  326.   Idents_tIdent Ident;
  327.   struct S_15 Selector;
  328.   Strings_tString String;
  329.  
  330.   InfoFile = IO_ReadOpen(Scanner_InfoFileName.A, 256L);
  331.   if (InfoFile < 0) {
  332.     IO_WriteS((System_tFile)IO_StdError, MissingInfo, 37L);
  333.     IO_WriteNl((System_tFile)IO_StdError);
  334.     IO_CloseIO();
  335.     exit(1);
  336.   }
  337.   Strings_ReadL(InfoFile, &TheWord);
  338.   switch (Strings_Char(&TheWord, 1)) {
  339.   case 'm':;
  340.     Language = Modula;
  341.     break;
  342.   case 'c':;
  343.     Language = C;
  344.     break;
  345.   default :
  346.     break;
  347.   }
  348.   Skip();
  349.   Skip();
  350.   while (!IO_EndOfFile(InfoFile)) {
  351.     t = IO_ReadI(InfoFile);
  352.     c = IO_ReadC(InfoFile);
  353.     c = IO_ReadC(InfoFile);
  354.     c = IO_ReadC(InfoFile);
  355.     i = 0;
  356.     do {
  357.       Selector.A[i] = IO_ReadC(InfoFile);
  358.       INC(i);
  359.     } while (!(Selector.A[i - 1] == ' '));
  360.     Selector.A[i - 1] = '\0';
  361.     Strings_ArrayToString(Selector.A, 256L, &String);
  362.     Strings_ReadL(InfoFile, &TheWord);
  363.     Ident = Idents_MakeIdent(&TheWord);
  364.     TokenCode.A[Ident] = t;
  365.     TokenSelector.A[Ident] = StringMem_PutString(&String);
  366.   }
  367.   IO_ReadClose(InfoFile);
  368.   LastIdent = Idents_MaxIdent();
  369. }
  370.  
  371. static void WriteIdent
  372. # ifdef __STDC__
  373. (Strings_tString *TheWord)
  374. # else
  375. (TheWord)
  376. Strings_tString *TheWord;
  377. # endif
  378. {
  379.   struct S_17 s;
  380.   CARDINAL j;
  381.  
  382.   Strings_StringToArray(TheWord, s.A, 256L);
  383.   s.A[Strings_Length(TheWord)] = '\'';
  384.   if (!BothFlag && (Strings_IsEqual(TheWord, &Not1) || Strings_IsEqual(TheWord, &Not2) || Strings_IsEqual(TheWord, &Not3) || Strings_IsEqual(TheWord, &Any1) || Strings_IsEqual(TheWord, &Any2) || Strings_IsEqual(TheWord, &Any3))) {
  385.     IO_WriteC((System_tFile)IO_StdOutput, '\\');
  386.   }
  387.   if (s.A[0] == '\'' || s.A[0] == '"') {
  388.     j = 1;
  389.   } else {
  390.     j = 0;
  391.   }
  392.   do {
  393.     if (BothFlag) {
  394.       switch (s.A[j]) {
  395.       case 'a':;
  396.       case 'b':;
  397.       case 'c':;
  398.       case 'd':;
  399.       case 'e':;
  400.       case 'f':;
  401.       case 'g':;
  402.       case 'h':;
  403.       case 'i':;
  404.       case 'j':;
  405.       case 'k':;
  406.       case 'l':;
  407.       case 'm':;
  408.       case 'n':;
  409.       case 'o':;
  410.       case 'p':;
  411.       case 'q':;
  412.       case 'r':;
  413.       case 's':;
  414.       case 't':;
  415.       case 'u':;
  416.       case 'v':;
  417.       case 'w':;
  418.       case 'x':;
  419.       case 'y':;
  420.       case 'z':;
  421.         IO_WriteC((System_tFile)IO_StdOutput, '{');
  422.         IO_WriteC((System_tFile)IO_StdOutput, s.A[j]);
  423.         IO_WriteC((System_tFile)IO_StdOutput, CAP(s.A[j]));
  424.         IO_WriteC((System_tFile)IO_StdOutput, '}');
  425.         break;
  426.       case 'A':;
  427.       case 'B':;
  428.       case 'C':;
  429.       case 'D':;
  430.       case 'E':;
  431.       case 'F':;
  432.       case 'G':;
  433.       case 'H':;
  434.       case 'I':;
  435.       case 'J':;
  436.       case 'K':;
  437.       case 'L':;
  438.       case 'M':;
  439.       case 'N':;
  440.       case 'O':;
  441.       case 'P':;
  442.       case 'Q':;
  443.       case 'R':;
  444.       case 'S':;
  445.       case 'T':;
  446.       case 'U':;
  447.       case 'V':;
  448.       case 'W':;
  449.       case 'X':;
  450.       case 'Y':;
  451.       case 'Z':;
  452.         IO_WriteC((System_tFile)IO_StdOutput, '{');
  453.         IO_WriteC((System_tFile)IO_StdOutput, CHR(ORD(s.A[j]) - ORD('A') + ORD('a')));
  454.         IO_WriteC((System_tFile)IO_StdOutput, s.A[j]);
  455.         IO_WriteC((System_tFile)IO_StdOutput, '}');
  456.         break;
  457.       case '0':;
  458.       case '1':;
  459.       case '2':;
  460.       case '3':;
  461.       case '4':;
  462.       case '5':;
  463.       case '6':;
  464.       case '7':;
  465.       case '8':;
  466.       case '9':;
  467.       case '_':;
  468.         IO_WriteC((System_tFile)IO_StdOutput, s.A[j]);
  469.         break;
  470.       default :
  471.         IO_WriteC((System_tFile)IO_StdOutput, '\\');
  472.         IO_WriteC((System_tFile)IO_StdOutput, s.A[j]);
  473.         break;
  474.       }
  475.     } else {
  476.       switch (s.A[j]) {
  477.       case '0':;
  478.       case '1':;
  479.       case '2':;
  480.       case '3':;
  481.       case '4':;
  482.       case '5':;
  483.       case '6':;
  484.       case '7':;
  485.       case '8':;
  486.       case '9':;
  487.       case 'A':;
  488.       case 'B':;
  489.       case 'C':;
  490.       case 'D':;
  491.       case 'E':;
  492.       case 'F':;
  493.       case 'G':;
  494.       case 'H':;
  495.       case 'I':;
  496.       case 'J':;
  497.       case 'K':;
  498.       case 'L':;
  499.       case 'M':;
  500.       case 'N':;
  501.       case 'O':;
  502.       case 'P':;
  503.       case 'Q':;
  504.       case 'R':;
  505.       case 'S':;
  506.       case 'T':;
  507.       case 'U':;
  508.       case 'V':;
  509.       case 'W':;
  510.       case 'X':;
  511.       case 'Y':;
  512.       case 'Z':;
  513.       case 'a':;
  514.       case 'b':;
  515.       case 'c':;
  516.       case 'd':;
  517.       case 'e':;
  518.       case 'f':;
  519.       case 'g':;
  520.       case 'h':;
  521.       case 'i':;
  522.       case 'j':;
  523.       case 'k':;
  524.       case 'l':;
  525.       case 'm':;
  526.       case 'n':;
  527.       case 'o':;
  528.       case 'p':;
  529.       case 'q':;
  530.       case 'r':;
  531.       case 's':;
  532.       case 't':;
  533.       case 'u':;
  534.       case 'v':;
  535.       case 'w':;
  536.       case 'x':;
  537.       case 'y':;
  538.       case 'z':;
  539.       case '_':;
  540.         IO_WriteC((System_tFile)IO_StdOutput, s.A[j]);
  541.         break;
  542.       default :
  543.         IO_WriteC((System_tFile)IO_StdOutput, '\\');
  544.         IO_WriteC((System_tFile)IO_StdOutput, s.A[j]);
  545.         break;
  546.       }
  547.     }
  548.     INC(j);
  549.   } while (!(s.A[j] == '"' || s.A[j] == '\''));
  550. }
  551.  
  552. static void InsertRules
  553. # ifdef __STDC__
  554. ()
  555. # else
  556. ()
  557. # endif
  558. {
  559.   CARDINAL Code;
  560.   CHAR c, Ch;
  561.   struct S_16 Selector;
  562.   CARDINAL i;
  563.  
  564.   InfoFile = IO_ReadOpen(Scanner_InfoFileName.A, 256L);
  565.   Skip();
  566.   Skip();
  567.   while (!IO_EndOfFile(InfoFile)) {
  568.     Code = IO_ReadI(InfoFile);
  569.     c = IO_ReadC(InfoFile);
  570.     Ch = IO_ReadC(InfoFile);
  571.     c = IO_ReadC(InfoFile);
  572.     i = 0;
  573.     do {
  574.       Selector.A[i] = IO_ReadC(InfoFile);
  575.       INC(i);
  576.     } while (!(Selector.A[i - 1] == ' '));
  577.     Selector.A[i - 1] = '\0';
  578.     Strings_ReadL(InfoFile, &TheWord);
  579.     if (Ch != 'S') {
  580.       Strings_WriteS((System_tFile)IO_StdOutput, &StartString);
  581.       WriteIdent(&TheWord);
  582.       IO_WriteC((System_tFile)IO_StdOutput, '\t');
  583.       IO_WriteS((System_tFile)IO_StdOutput, (STRING)": { ", 4L);
  584.       Strings_WriteS((System_tFile)IO_StdOutput, &InsText);
  585.       switch (Language) {
  586.       case Modula:;
  587.         IO_WriteS((System_tFile)IO_StdOutput, (STRING)"RETURN ", 7L);
  588.         break;
  589.       case C:;
  590.         IO_WriteS((System_tFile)IO_StdOutput, (STRING)"return ", 7L);
  591.         break;
  592.       }
  593.       IO_WriteI((System_tFile)IO_StdOutput, (LONGINT)Code, 0L);
  594.       IO_WriteS((System_tFile)IO_StdOutput, (STRING)"; }", 3L);
  595.       IO_WriteNl((System_tFile)IO_StdOutput);
  596.     }
  597.   }
  598.   IO_ReadClose(InfoFile);
  599. }
  600.  
  601. INTEGER Scanner_GetToken
  602. # ifdef __STDC__
  603. ()
  604. # else
  605. ()
  606. # endif
  607. {
  608.   yyStateRange yyState;
  609.   yyCombTypePtr yyTablePtr;
  610.   BOOLEAN yyRestartFlag;
  611.   SHORTINT yyi;
  612.  
  613.   for (;;) {
  614.     yyState = yyStartState;
  615.     Scanner_TokenLength = 0;
  616.     for (;;) {
  617.       for (;;) {
  618.         yyTablePtr = (yyCombTypePtr)(yyBasePtr.A[yyState] + ORD(yyChBufferPtr->A[yyChBufferIndex]) * sizeof(yyCombType));
  619.         if (yyTablePtr->Check != yyState) {
  620.           yyState = yyDefault.A[yyState];
  621.           if (yyState == yyDNoState) {
  622.             goto EXIT_4;
  623.           }
  624.         } else {
  625.           yyState = yyTablePtr->Next;
  626.           INC(Scanner_TokenLength);
  627.           yyStateStack.A[Scanner_TokenLength] = yyState;
  628.           INC(yyChBufferIndex);
  629.         }
  630.       } EXIT_4:;
  631.       for (;;) {
  632.         switch (yyStateStack.A[Scanner_TokenLength]) {
  633.         case 154:;
  634.           yyStart(Action);
  635.           yyEcho();
  636.           Level = 1;
  637.           yyRestartFlag = FALSE;
  638.           goto EXIT_5;
  639.           break;
  640.         case 29:;
  641.           yyStart(Rules);
  642.           yyEcho();
  643.           yyRestartFlag = FALSE;
  644.           goto EXIT_5;
  645.           break;
  646.         case 19:;
  647.           DoText();
  648.           yyRestartFlag = FALSE;
  649.           goto EXIT_5;
  650.           break;
  651.         case 17:;
  652.           yyStart(Start);
  653.           BothFlag = FALSE;
  654.           yyRestartFlag = FALSE;
  655.           goto EXIT_5;
  656.           break;
  657.         case 18:;
  658.           yyStart(Start);
  659.           BothFlag = TRUE;
  660.           yyRestartFlag = FALSE;
  661.           goto EXIT_5;
  662.           break;
  663.         case 15:;
  664.         case 39:;
  665.           yyStart(Action);
  666.           yyEcho();
  667.           Level = 0;
  668.           yyRestartFlag = FALSE;
  669.           goto EXIT_5;
  670.           break;
  671.         case 153:;
  672.           yyStart(Set);
  673.           yyEcho();
  674.           yyRestartFlag = FALSE;
  675.           goto EXIT_5;
  676.           break;
  677.         case 152:;
  678.           yyPrevious();
  679.           yyEcho();
  680.           yyRestartFlag = FALSE;
  681.           goto EXIT_5;
  682.           break;
  683.         case 151:;
  684.           yyPrevious();
  685.           InsertRules();
  686.           yyRestartFlag = FALSE;
  687.           goto EXIT_5;
  688.           break;
  689.         case 24:;
  690.           yyPrevious();
  691.           Scanner_GetWord(&StartString);
  692.           InsertRules();
  693.           yyRestartFlag = FALSE;
  694.           goto EXIT_5;
  695.           break;
  696.         case 25:;
  697.           while (yyStateStack.A[Scanner_TokenLength] != 24) {
  698.             DEC(yyChBufferIndex);
  699.             DEC(Scanner_TokenLength);
  700.           }
  701.           Scanner_GetWord(&StartString);
  702.           yyStartState = Action;
  703.           Level = 0;
  704.           IsCollecting = TRUE;
  705.           yyRestartFlag = FALSE;
  706.           goto EXIT_5;
  707.           break;
  708.         case 26:;
  709.           DEC1(yyChBufferIndex, 1);
  710.           DEC1(Scanner_TokenLength, 1);
  711.           yyStartState = Action;
  712.           Level = 0;
  713.           IsCollecting = TRUE;
  714.           yyRestartFlag = FALSE;
  715.           goto EXIT_5;
  716.           break;
  717.         case 22:;
  718.           GenPosition();
  719.           yyRestartFlag = FALSE;
  720.           goto EXIT_5;
  721.           break;
  722.         case 21:;
  723.           GenScanAttr();
  724.           yyRestartFlag = FALSE;
  725.           goto EXIT_5;
  726.           break;
  727.         case 23:;
  728.           GenErrorAttr();
  729.           yyRestartFlag = FALSE;
  730.           goto EXIT_5;
  731.           break;
  732.         case 150:;
  733.           DoText();
  734.           INC(Level);
  735.           yyRestartFlag = FALSE;
  736.           goto EXIT_5;
  737.           break;
  738.         case 149:;
  739.           DEC(Level);
  740.           if (Level > 0) {
  741.             DoText();
  742.           } else {
  743.             yyPrevious();
  744.             if (IsCollecting) {
  745.               InsertRules();
  746.               IsCollecting = FALSE;
  747.             } else {
  748.               yyEcho();
  749.             }
  750.           }
  751.           yyRestartFlag = FALSE;
  752.           goto EXIT_5;
  753.           break;
  754.         case 148:;
  755.           yyStartState = Return;
  756.           DoText();
  757.           Returning = FALSE;
  758.           yyRestartFlag = FALSE;
  759.           goto EXIT_5;
  760.           break;
  761.         case 20:;
  762.           yyStartState = Return;
  763.           DoText();
  764.           Returning = TRUE;
  765.           yyRestartFlag = FALSE;
  766.           goto EXIT_5;
  767.           break;
  768.         case 27:;
  769.           yyStartState = Action;
  770.           DoIdent();
  771.           yyRestartFlag = FALSE;
  772.           goto EXIT_5;
  773.           break;
  774.         case 28:;
  775.           yyStartState = Action;
  776.           DoIdent();
  777.           yyRestartFlag = FALSE;
  778.           goto EXIT_5;
  779.           break;
  780.         case 13:;
  781.         case 30:;
  782.         case 31:;
  783.         case 32:;
  784.         case 33:;
  785.         case 34:;
  786.         case 35:;
  787.         case 36:;
  788.         case 37:;
  789.         case 48:;
  790.         case 49:;
  791.         case 65:;
  792.         case 116:;
  793.         case 117:;
  794.         case 130:;
  795.         case 135:;
  796.         case 136:;
  797.         case 137:;
  798.         case 138:;
  799.         case 139:;
  800.           DoText();
  801.           yyRestartFlag = FALSE;
  802.           goto EXIT_5;
  803.           break;
  804.         case 14:;
  805.         case 38:;
  806.           DoText();
  807.           yyRestartFlag = FALSE;
  808.           goto EXIT_5;
  809.           break;
  810.         case 134:;
  811.           DoText();
  812.           yyRestartFlag = FALSE;
  813.           goto EXIT_5;
  814.           break;
  815.         case 1:;
  816.         case 2:;
  817.         case 3:;
  818.         case 4:;
  819.         case 5:;
  820.         case 6:;
  821.         case 7:;
  822.         case 8:;
  823.         case 9:;
  824.         case 10:;
  825.         case 11:;
  826.         case 12:;
  827.         case 16:;
  828.         case 40:;
  829.         case 41:;
  830.         case 42:;
  831.         case 43:;
  832.         case 44:;
  833.         case 45:;
  834.         case 46:;
  835.         case 47:;
  836.         case 50:;
  837.         case 51:;
  838.         case 52:;
  839.         case 53:;
  840.         case 54:;
  841.         case 55:;
  842.         case 56:;
  843.         case 57:;
  844.         case 58:;
  845.         case 59:;
  846.         case 60:;
  847.         case 61:;
  848.         case 62:;
  849.         case 63:;
  850.         case 64:;
  851.         case 66:;
  852.         case 67:;
  853.         case 68:;
  854.         case 69:;
  855.         case 70:;
  856.         case 71:;
  857.         case 72:;
  858.         case 73:;
  859.         case 74:;
  860.         case 75:;
  861.         case 76:;
  862.         case 77:;
  863.         case 78:;
  864.         case 79:;
  865.         case 80:;
  866.         case 81:;
  867.         case 82:;
  868.         case 83:;
  869.         case 84:;
  870.         case 85:;
  871.         case 86:;
  872.         case 87:;
  873.         case 88:;
  874.         case 89:;
  875.         case 90:;
  876.         case 91:;
  877.         case 92:;
  878.         case 93:;
  879.         case 94:;
  880.         case 95:;
  881.         case 96:;
  882.         case 97:;
  883.         case 98:;
  884.         case 99:;
  885.         case 100:;
  886.         case 101:;
  887.         case 102:;
  888.         case 103:;
  889.         case 104:;
  890.         case 105:;
  891.         case 106:;
  892.         case 107:;
  893.         case 108:;
  894.         case 109:;
  895.         case 110:;
  896.         case 111:;
  897.         case 112:;
  898.         case 113:;
  899.         case 114:;
  900.         case 115:;
  901.         case 118:;
  902.         case 119:;
  903.         case 120:;
  904.         case 121:;
  905.         case 122:;
  906.         case 123:;
  907.         case 124:;
  908.         case 125:;
  909.         case 126:;
  910.         case 127:;
  911.         case 128:;
  912.         case 129:;
  913.         case 131:;
  914.         case 140:;
  915.         case 141:;
  916.         case 142:;
  917.         case 143:;
  918.         case 144:;
  919.         case 145:;
  920.         case 146:;
  921.         case 147:;
  922.           DEC(yyChBufferIndex);
  923.           DEC(Scanner_TokenLength);
  924.           break;
  925.         case 133:;
  926.           Scanner_Attribute.Position.Line = yyLineCount;
  927.           Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart;
  928.           INC(yyChBufferIndex);
  929.           Scanner_TokenLength = 1;
  930.           IO_WriteC((System_tFile)IO_StdOutput, yyChBufferPtr->A[yyChBufferIndex - 1]);
  931.           yyRestartFlag = FALSE;
  932.           goto EXIT_5;
  933.           break;
  934.         case yyDNoState:;
  935.           yyGetTables();
  936.           yyStateStack.A[0] = yyDefaultState;
  937.           if (yyFileStackPtr == 0) {
  938.             yyInitialize();
  939.             yySourceFile = System_StdInput;
  940.           }
  941.           yyRestartFlag = FALSE;
  942.           goto EXIT_5;
  943.           break;
  944.         case 132:;
  945.           DEC(yyChBufferIndex);
  946.           DEC(Scanner_TokenLength);
  947.           if (Scanner_TokenLength == 0) {
  948.             yyState = yyStartState;
  949.           } else {
  950.             yyState = yyStateStack.A[Scanner_TokenLength];
  951.           }
  952.           if ((SHORTINT)yyChBufferIndex != yyBytesRead + yyTokenLngMax + 1) {
  953.             yyState = yyEobTrans.A[yyState];
  954.             if (yyState != yyDNoState) {
  955.               INC(yyChBufferIndex);
  956.               INC(Scanner_TokenLength);
  957.               yyStateStack.A[Scanner_TokenLength] = yyState;
  958.               yyRestartFlag = TRUE;
  959.               goto EXIT_5;
  960.             }
  961.           } else {
  962.             for (yyi = -(INTEGER)Scanner_TokenLength; yyi <= -1; yyi += 1) {
  963.               yyChBufferPtr->A[yyTokenLngMax + 1 + yyi] = yyChBufferPtr->A[(SHORTINT)yyChBufferIndex + yyi];
  964.             }
  965.             if (!yyEof) {
  966.               DEC1(yyLineStart, yyBytesRead);
  967.               yyChBufferIndex = yyTokenLngMax + 1;
  968.               yyBytesRead = Source_GetLine(yySourceFile, ADR(yyChBufferPtr->A[yyChBufferIndex]), (LONGCARD)yyChBufferSize);
  969.               if (yyBytesRead <= 0) {
  970.                 yyBytesRead = 0;
  971.                 yyEof = TRUE;
  972.               }
  973.               yyChBufferPtr->A[yyBytesRead + yyTokenLngMax + 1] = yyEobCh;
  974.               yyChBufferPtr->A[yyBytesRead + yyTokenLngMax + 2] = '\0';
  975.               yyRestartFlag = TRUE;
  976.               goto EXIT_5;
  977.             }
  978.             if (Scanner_TokenLength == 0) {
  979.               Scanner_Attribute.Position.Line = yyLineCount;
  980.               Scanner_Attribute.Position.Column = yyChBufferIndex - yyLineStart;
  981.               Scanner_CloseFile();
  982.               if (yyFileStackPtr == 0) {
  983.               }
  984.               if (yyFileStackPtr == 0) {
  985.                 return Scanner_EofToken;
  986.               }
  987.               yyRestartFlag = FALSE;
  988.               goto EXIT_5;
  989.             }
  990.           }
  991.           break;
  992.         default :
  993.           if (Scanner_TokenLength >= yyTokenLngMax) {
  994.             yyErrorMessage(1);
  995.           } else {
  996.             yyErrorMessage(0);
  997.           }
  998.           break;
  999.         }
  1000.       } EXIT_5:;
  1001.       if (yyRestartFlag) {
  1002.       } else {
  1003.         goto EXIT_3;
  1004.       }
  1005.     } EXIT_3:;
  1006.   } EXIT_2:;
  1007. }
  1008.  
  1009. void Scanner_BeginFile
  1010. # ifdef __STDC__
  1011. (CHAR FileName[], LONGCARD O_1)
  1012. # else
  1013. (FileName, O_1)
  1014. CHAR FileName[];
  1015. LONGCARD O_1;
  1016. # endif
  1017. {
  1018.   OPEN_ARRAY_LOCALS
  1019.  
  1020.   ALLOC_OPEN_ARRAYS(O_1 * sizeof(CHAR), 1)
  1021.   COPY_OPEN_ARRAY(FileName, O_1, CHAR)
  1022.   if (yyStateStack.A[0] == yyDNoState) {
  1023.     yyGetTables();
  1024.     yyStateStack.A[0] = yyDefaultState;
  1025.   }
  1026.   yyInitialize();
  1027.   yySourceFile = Source_BeginSource(FileName, O_1);
  1028.   FREE_OPEN_ARRAYS
  1029. }
  1030.  
  1031. static void yyInitialize
  1032. # ifdef __STDC__
  1033. ()
  1034. # else
  1035. ()
  1036. # endif
  1037. {
  1038.   if (yyFileStackPtr >= yyFileStackSize) {
  1039.     yyErrorMessage(3);
  1040.   }
  1041.   INC(yyFileStackPtr);
  1042.   {
  1043.     register struct S_13 *W_1 = &yyFileStack.A[yyFileStackPtr - 1];
  1044.  
  1045.     W_1->SourceFile = yySourceFile;
  1046.     W_1->ChBufferPtr = yyChBufferPtr;
  1047.     W_1->ChBufferIndex = yyChBufferIndex;
  1048.     W_1->BytesRead = yyBytesRead;
  1049.     W_1->Eof = yyEof;
  1050.     W_1->LineCount = yyLineCount;
  1051.     W_1->LineStart = yyLineStart;
  1052.   }
  1053.   yyChBufferPtr = (yyChBufferType)Memory_Alloc((LONGINT)(2307 - 0 + 1));
  1054.   yyChBufferPtr->A[yyTokenLngMax] = yyEolCh;
  1055.   yyChBufferPtr->A[yyTokenLngMax + 1] = yyEobCh;
  1056.   yyChBufferPtr->A[yyTokenLngMax + 2] = '\0';
  1057.   yyChBufferIndex = yyTokenLngMax + 1;
  1058.   yyBytesRead = 0;
  1059.   yyEof = FALSE;
  1060.   yyLineCount = 1;
  1061.   yyLineStart = yyTokenLngMax + yyBytesRead;
  1062. }
  1063.  
  1064. void Scanner_CloseFile
  1065. # ifdef __STDC__
  1066. ()
  1067. # else
  1068. ()
  1069. # endif
  1070. {
  1071.   if (yyFileStackPtr == 0) {
  1072.     yyErrorMessage(4);
  1073.   }
  1074.   Source_CloseSource(yySourceFile);
  1075.   Memory_Free((LONGINT)(2307 - 0 + 1), (ADDRESS)yyChBufferPtr);
  1076.   {
  1077.     register struct S_13 *W_2 = &yyFileStack.A[yyFileStackPtr - 1];
  1078.  
  1079.     yySourceFile = W_2->SourceFile;
  1080.     yyChBufferPtr = W_2->ChBufferPtr;
  1081.     yyChBufferIndex = W_2->ChBufferIndex;
  1082.     yyBytesRead = W_2->BytesRead;
  1083.     yyEof = W_2->Eof;
  1084.     yyLineCount = W_2->LineCount;
  1085.     yyLineStart = W_2->LineStart;
  1086.   }
  1087.   DEC(yyFileStackPtr);
  1088. }
  1089.  
  1090. void Scanner_GetWord
  1091. # ifdef __STDC__
  1092. (Strings_tString *Word)
  1093. # else
  1094. (Word)
  1095. Strings_tString *Word;
  1096. # endif
  1097. {
  1098.   CARDINAL i;
  1099.   yyChBufferRange WordStart;
  1100.  
  1101.   WordStart = yyChBufferIndex - Scanner_TokenLength - 1;
  1102.   {
  1103.     LONGCARD B_1 = 1, B_2 = Scanner_TokenLength;
  1104.  
  1105.     if (B_1 <= B_2)
  1106.       for (i = B_1;; i += 1) {
  1107.         Word->Chars.A[i] = yyChBufferPtr->A[WordStart + i];
  1108.         if (i >= B_2) break;
  1109.       }
  1110.   }
  1111.   Word->Length = Scanner_TokenLength;
  1112. }
  1113.  
  1114. void Scanner_GetLower
  1115. # ifdef __STDC__
  1116. (Strings_tString *Word)
  1117. # else
  1118. (Word)
  1119. Strings_tString *Word;
  1120. # endif
  1121. {
  1122.   CARDINAL i;
  1123.   yyChBufferRange WordStart;
  1124.  
  1125.   WordStart = yyChBufferIndex - Scanner_TokenLength - 1;
  1126.   {
  1127.     LONGCARD B_3 = 1, B_4 = Scanner_TokenLength;
  1128.  
  1129.     if (B_3 <= B_4)
  1130.       for (i = B_3;; i += 1) {
  1131.         Word->Chars.A[i] = yyToLower.A[yyChBufferPtr->A[WordStart + i]];
  1132.         if (i >= B_4) break;
  1133.       }
  1134.   }
  1135.   Word->Length = Scanner_TokenLength;
  1136. }
  1137.  
  1138. void Scanner_GetUpper
  1139. # ifdef __STDC__
  1140. (Strings_tString *Word)
  1141. # else
  1142. (Word)
  1143. Strings_tString *Word;
  1144. # endif
  1145. {
  1146.   CARDINAL i;
  1147.   yyChBufferRange WordStart;
  1148.  
  1149.   WordStart = yyChBufferIndex - Scanner_TokenLength - 1;
  1150.   {
  1151.     LONGCARD B_5 = 1, B_6 = Scanner_TokenLength;
  1152.  
  1153.     if (B_5 <= B_6)
  1154.       for (i = B_5;; i += 1) {
  1155.         Word->Chars.A[i] = yyToUpper.A[yyChBufferPtr->A[WordStart + i]];
  1156.         if (i >= B_6) break;
  1157.       }
  1158.   }
  1159.   Word->Length = Scanner_TokenLength;
  1160. }
  1161.  
  1162. static void yyStart
  1163. # ifdef __STDC__
  1164. (yyStateRange State)
  1165. # else
  1166. (State)
  1167. yyStateRange State;
  1168. # endif
  1169. {
  1170.   yyPreviousStart = yyStartState;
  1171.   yyStartState = State;
  1172. }
  1173.  
  1174. static void yyPrevious
  1175. # ifdef __STDC__
  1176. ()
  1177. # else
  1178. ()
  1179. # endif
  1180. {
  1181.   yyStateRange s;
  1182.  
  1183.   s = yyStartState;
  1184.   yyStartState = yyPreviousStart;
  1185.   yyPreviousStart = s;
  1186. }
  1187.  
  1188. static void yyEcho
  1189. # ifdef __STDC__
  1190. ()
  1191. # else
  1192. ()
  1193. # endif
  1194. {
  1195.   Strings_tString Word;
  1196.  
  1197.   Scanner_GetWord(&Word);
  1198.   Strings_WriteS((System_tFile)IO_StdOutput, &Word);
  1199. }
  1200.  
  1201. static void yyLess
  1202. # ifdef __STDC__
  1203. (CARDINAL n)
  1204. # else
  1205. (n)
  1206. CARDINAL n;
  1207. # endif
  1208. {
  1209.   DEC1(yyChBufferIndex, Scanner_TokenLength - n);
  1210.   Scanner_TokenLength = n;
  1211. }
  1212.  
  1213. static void yyTab
  1214. # ifdef __STDC__
  1215. ()
  1216. # else
  1217. ()
  1218. # endif
  1219. {
  1220.   DEC1(yyLineStart, 7 - (yyChBufferIndex - yyLineStart - 2) % 8);
  1221. }
  1222.  
  1223. static void yyTab1
  1224. # ifdef __STDC__
  1225. (CARDINAL a)
  1226. # else
  1227. (a)
  1228. CARDINAL a;
  1229. # endif
  1230. {
  1231.   DEC1(yyLineStart, 7 - (yyChBufferIndex - yyLineStart - Scanner_TokenLength + a - 1) % 8);
  1232. }
  1233.  
  1234. static void yyTab2
  1235. # ifdef __STDC__
  1236. (CARDINAL a, CARDINAL b)
  1237. # else
  1238. (a, b)
  1239. CARDINAL a, b;
  1240. # endif
  1241. {
  1242.   DEC1(yyLineStart, 7 - (yyChBufferIndex - yyLineStart - Scanner_TokenLength + a - 1) % 8);
  1243. }
  1244.  
  1245. static void yyEol
  1246. # ifdef __STDC__
  1247. (CARDINAL Column)
  1248. # else
  1249. (Column)
  1250. CARDINAL Column;
  1251. # endif
  1252. {
  1253.   INC(yyLineCount);
  1254.   yyLineStart = yyChBufferIndex - 1 - Column;
  1255. }
  1256.  
  1257. static void output
  1258. # ifdef __STDC__
  1259. (CHAR c)
  1260. # else
  1261. (c)
  1262. CHAR c;
  1263. # endif
  1264. {
  1265.   IO_WriteC((System_tFile)IO_StdOutput, c);
  1266. }
  1267.  
  1268. static void unput
  1269. # ifdef __STDC__
  1270. (CHAR c)
  1271. # else
  1272. (c)
  1273. CHAR c;
  1274. # endif
  1275. {
  1276.   DEC(yyChBufferIndex);
  1277.   yyChBufferPtr->A[yyChBufferIndex] = c;
  1278. }
  1279.  
  1280. static CHAR input
  1281. # ifdef __STDC__
  1282. ()
  1283. # else
  1284. ()
  1285. # endif
  1286. {
  1287.   if ((SHORTINT)yyChBufferIndex == yyBytesRead + yyTokenLngMax + 1) {
  1288.     if (!yyEof) {
  1289.       DEC1(yyLineStart, yyBytesRead);
  1290.       yyChBufferIndex = yyTokenLngMax + 1;
  1291.       yyBytesRead = Source_GetLine(yySourceFile, ADR(yyChBufferPtr->A[yyChBufferIndex]), (LONGCARD)yyChBufferSize);
  1292.       if (yyBytesRead <= 0) {
  1293.         yyBytesRead = 0;
  1294.         yyEof = TRUE;
  1295.       }
  1296.       yyChBufferPtr->A[yyBytesRead + yyTokenLngMax + 1] = yyEobCh;
  1297.       yyChBufferPtr->A[yyBytesRead + yyTokenLngMax + 2] = '\0';
  1298.     }
  1299.   }
  1300.   if ((SHORTINT)yyChBufferIndex == yyBytesRead + yyTokenLngMax + 1) {
  1301.     return '\0';
  1302.   } else {
  1303.     INC(yyChBufferIndex);
  1304.     return yyChBufferPtr->A[yyChBufferIndex - 1];
  1305.   }
  1306. }
  1307.  
  1308. void Scanner_BeginScanner
  1309. # ifdef __STDC__
  1310. ()
  1311. # else
  1312. ()
  1313. # endif
  1314. {
  1315.   (void)strncpy((char *)Scanner_InfoFileName.A, "Scanner.rpp", sizeof(Scanner_InfoFileName.A));
  1316.   Language = Modula;
  1317.   if (GetArgCount() > 1) {
  1318.     GetArgument(1L, Scanner_ScanTabName.A, 128L);
  1319.   }
  1320.   if (GetArgCount() > 2) {
  1321.     GetArgument(2L, Scanner_InfoFileName.A, 256L);
  1322.   }
  1323.   IsCollecting = FALSE;
  1324.   Idents_InitIdents();
  1325.   ReadIdents();
  1326.   Strings_AssignEmpty(&InsText);
  1327.   Strings_AssignEmpty(&StartString);
  1328.   Strings_ArrayToString((STRING)"NOT", 3L, &Not1);
  1329.   Strings_ArrayToString((STRING)"'NOT'", 5L, &Not2);
  1330.   Strings_ArrayToString((STRING)"\"NOT\"", 5L, &Not3);
  1331.   Strings_ArrayToString((STRING)"ANY", 3L, &Any1);
  1332.   Strings_ArrayToString((STRING)"'ANY'", 5L, &Any2);
  1333.   Strings_ArrayToString((STRING)"\"ANY\"", 5L, &Any3);
  1334. }
  1335.  
  1336. void Scanner_CloseScanner
  1337. # ifdef __STDC__
  1338. ()
  1339. # else
  1340. ()
  1341. # endif
  1342. {
  1343. }
  1344.  
  1345. static void yyGetTables
  1346. # ifdef __STDC__
  1347. ()
  1348. # else
  1349. ()
  1350. # endif
  1351. {
  1352.   CARDINAL BlockSize, j, n;
  1353.   System_tFile TableFile;
  1354.   yyStateRange i;
  1355.   struct S_18 Base;
  1356.  
  1357.   BlockSize = 64000 / sizeof(yyCombType);
  1358.   TableFile = OpenInput(Scanner_ScanTabName.A, 128L);
  1359.   Checks_ErrorCheck((STRING)"yyGetTables.OpenInput", 21L, TableFile);
  1360.   if (yyGetTable(TableFile, ADR(Base)) / sizeof(yyTableElmt) - 1 != yyDStateCount || yyGetTable(TableFile, ADR(yyDefault)) / sizeof(yyTableElmt) - 1 != yyDStateCount || yyGetTable(TableFile, ADR(yyEobTrans)) / sizeof(yyTableElmt) - 1 != yyDStateCount) {
  1361.     yyErrorMessage(2);
  1362.   }
  1363.   n = 0;
  1364.   j = 0;
  1365.   while (j <= yyTableSize) {
  1366.     INC1(n, yyGetTable(TableFile, ADR(yyComb.A[j])) / sizeof(yyCombType));
  1367.     INC1(j, BlockSize);
  1368.   }
  1369.   if (n != yyTableSize + 1) {
  1370.     yyErrorMessage(2);
  1371.   }
  1372.   Close(TableFile);
  1373.   for (i = 0; i <= yyDStateCount; i += 1) {
  1374.     yyBasePtr.A[i] = (LONGCARD)ADR(yyComb.A[Base.A[i]]);
  1375.   }
  1376. }
  1377.  
  1378. static CARDINAL yyGetTable
  1379. # ifdef __STDC__
  1380. (System_tFile TableFile, ADDRESS Address)
  1381. # else
  1382. (TableFile, Address)
  1383. System_tFile TableFile;
  1384. ADDRESS Address;
  1385. # endif
  1386. {
  1387.   INTEGER N;
  1388.   yyTableElmt Length;
  1389.  
  1390.   N = Read(TableFile, ADR(Length), (LONGCARD)sizeof(yyTableElmt));
  1391.   Checks_ErrorCheck((STRING)"yyGetTable.Read1", 16L, N);
  1392.   N = Read(TableFile, Address, (LONGCARD)Length);
  1393.   Checks_ErrorCheck((STRING)"yyGetTable.Read2", 16L, N);
  1394.   return Length;
  1395. }
  1396.  
  1397. static void yyErrorMessage
  1398. # ifdef __STDC__
  1399. (SHORTCARD ErrorCode)
  1400. # else
  1401. (ErrorCode)
  1402. SHORTCARD ErrorCode;
  1403. # endif
  1404. {
  1405.   Positions_WritePosition((System_tFile)IO_StdError, Scanner_Attribute.Position);
  1406.   switch (ErrorCode) {
  1407.   case 0:;
  1408.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: internal error", 25L);
  1409.     break;
  1410.   case 1:;
  1411.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: token or lookahead too long", 38L);
  1412.     break;
  1413.   case 2:;
  1414.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: table mismatch", 25L);
  1415.     break;
  1416.   case 3:;
  1417.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: too many nested include files", 40L);
  1418.     break;
  1419.   case 4:;
  1420.     IO_WriteS((System_tFile)IO_StdError, (STRING)": Scanner: file stack underflow (too many calls of CloseFile)", 61L);
  1421.     break;
  1422.   }
  1423.   IO_WriteNl((System_tFile)IO_StdError);
  1424.   (*Scanner_Exit)();
  1425. }
  1426.  
  1427. static void yyExit
  1428. # ifdef __STDC__
  1429. ()
  1430. # else
  1431. ()
  1432. # endif
  1433. {
  1434.   IO_CloseIO();
  1435.   Exit(1L);
  1436. }
  1437.  
  1438. void BEGIN_Scanner()
  1439. {
  1440.   static BOOLEAN has_been_called = FALSE;
  1441.  
  1442.   if (!has_been_called) {
  1443.     has_been_called = TRUE;
  1444.  
  1445.     BEGIN_Strings();
  1446.     BEGIN_Positions();
  1447.     BEGIN_Checks();
  1448.     BEGIN_System();
  1449.     BEGIN_Positions();
  1450.     BEGIN_IO();
  1451.     BEGIN_Memory();
  1452.     BEGIN_Strings();
  1453.     BEGIN_Source();
  1454.     BEGIN_System();
  1455.     BEGIN_Strings();
  1456.     BEGIN_StringMem();
  1457.     BEGIN_Idents();
  1458.     BEGIN_IO();
  1459.  
  1460.     (void)strncpy((char *)Scanner_ScanTabName.A, "Scanner.Tab", sizeof(Scanner_ScanTabName.A));
  1461.     Scanner_Exit = yyExit;
  1462.     yyFileStackPtr = 0;
  1463.     yyStartState = 1;
  1464.     yyPreviousStart = 1;
  1465.     yyBasePtr.A[yyStartState] = (LONGCARD)ADR(yyComb.A[0]);
  1466.     yyDefault.A[yyStartState] = yyDNoState;
  1467.     yyComb.A[0].Check = yyDNoState;
  1468.     yyChBufferPtr = (yyChBufferType)ADR(yyComb.A[0]);
  1469.     yyChBufferIndex = 1;
  1470.     yyStateStack.A[0] = yyDNoState;
  1471.     for (yyCh = yyFirstCh; yyCh <= yyLastCh; yyCh += 1) {
  1472.       yyToLower.A[yyCh] = yyCh;
  1473.     }
  1474.     yyToUpper = yyToLower;
  1475.     for (yyCh = 'A'; yyCh <= 'Z'; yyCh += 1) {
  1476.       yyToLower.A[yyCh] = CHR(ORD(yyCh) - ORD('A') + ORD('a'));
  1477.     }
  1478.     for (yyCh = 'a'; yyCh <= 'z'; yyCh += 1) {
  1479.       yyToUpper.A[yyCh] = CHR(ORD(yyCh) - ORD('a') + ORD('A'));
  1480.     }
  1481.   }
  1482. }
  1483.